<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="<%=basePath%>"/>
    <title>${title }</title>
    <link href="css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">
        function getRound1(da) {
            // $("a").each(function () {
            //     document.getElementById($(this).attr("id")).click(function () {
            console.log("begin click...")
            //设置点击的a标签的class
            $(da).attr("class", "active")
			//其它标签设置为非红色
			v=$(da).attr("id")
			console.log(v)
			if($(da).attr("ty")==="day"){
				console.log("day")
				$("a[ty$='day'][id!=v]").attr("class","")
				$(da).attr("class", "active")
			}
			if($(da).attr("ty")==="hall"){
				console.log("hall")
				$("a[ty$='hall'][id!=v]").attr("class","")
				$(da).attr("class", "active")
			}
			if($(da).attr("ty")==="cinema"){
				console.log("hall")
				$("a[ty$='cinema'][id!=v]").attr("class","")
				$(da).attr("class", "active")
			}
            //获取点击标签
			var ownday = $("a[ty$='day'][class$='active']").attr("id")
			var hallid = $("a[ty$='hall'][class$='active']").attr("id")
            var cinemaid = $("a[ty$='cinema'][class$='active']").attr("id")
			var filmid ="${requestScope.goods.filmid}"

			console.log("ownday",ownday)
			console.log("filmid",filmid)
			if(hallid==undefined){
				hallid=""
			}
            if(cinemaid==undefined){
                cinemaid=""
            }
			if(ownday==undefined){
				ownday=""
			}
                //ajax刷新div
                $.ajax(
                    {
                        type: 'post',
                        url: 'round/getRounds.action',
                        data: {ownday: ownday, filmid: filmid, hallid: hallid,cinemaid:cinemaid},
                        dataType: 'html',
                        success: function (data) {
                            $('#mx').html(data)
                        },
                        error: function () {
                            alert('加载失败！')
                        }
                    }
                )
            // })
            // })
        }

        function goChoice(a){
            //获取变量 价格，日期，影院，影厅，场次
            var film="${requestScope.goods}"

            var ownday = $("a[ty$='day'][class$='active']").attr("id")
            var hallid = $("a[ty$='hall'][class$='active']").attr("id")
            var hallname=$("a[ty$='hall'][class$='active']").text()
            var cinemaid = $("a[ty$='cinema'][class$='active']").attr("id")
            var cinemaname = $("a[ty$='cinema'][class$='active']").text()

            if(ownday==null) {
                alert("请选择哪一天！")
                return
            }
            if(hallid==null) {
                alert("请选择影厅！")
                return
            }
            if(cinemaid==null) {
                alert("请选择影院！")
                return
            }
            //场次
            var tr=$(a).closest('tr'), td = tr.find('td');
            alert(tr[0].rowIndex)
            alert(td.eq(1).html())
        }

    </script>

</head>

<body>
<jsp:include page="header.jsp"></jsp:include>
<div class="block box">
    <div class="blank"></div>
    <div id="ur_here">
        当前位置: <a href=".">首页</a>
        <code> &gt; </code>
        <a href="index/all.action">全部电影</a>
        <code> &gt; </code>
        <a href="index/cate.action?id=${goods.cateid }">${goods.catename }</a>
        <code> &gt; </code>
        ${goods.filmname }
    </div>
</div>
<div class="blank"></div>
<div class="block clearfix">
    <div class="AreaL">
        <div id="category_tree">
            <div class="tit">所有电影分类</div>
            <dl class="clearfix" style="overflow: hidden;">
                <c:forEach items="${cateList}" var="cate">
                    <div class="box1 cate" id="cate">
                        <h1 style="border-top: none">
                            <a href="index/cate.action?id=${cate.cateid }" class="  f_l">${cate.catename }</a>
                        </h1>
                    </div>
                    <div style="clear: both"></div>
                </c:forEach>
            </dl>
        </div>
        <div class="blank"></div>
        <div class="box" id='history_div'>
            <div class="box_1">
                <h3>
                    <span>热门电影</span>
                </h3>
                <div class="boxCenterList clearfix" id='history_list'>
                    <c:forEach items="${hotList}" var="film">
                        <ul class="clearfix">
                            <li class="goodsimg"><a href="index/detail.action?id=${film.filmid }" target="_blank"><img
                                    src="${film.image }" alt="${film.filmname }" class="B_blue"/> </a></li>
                            <li><a href="index/detail.action?id=${film.filmid }" target="_blank"
                                   title="${film.filmname }">${film.filmname }</a>
                                <br/> 价格： <font class="f1">￥${film.price }元</font></li>
                        </ul>
                    </c:forEach>
                </div>
            </div>
        </div>
        <div class="blank5"></div>
    </div>
    <div class="AreaR">
        <div id="goodsInfo" class="clearfix">
            <div class="imgInfo">
                <img src="${goods.image}" alt="${goods.filmname }" width="360px;" height="360px"/>
                <div class="blank5"></div>
                <div class="blank"></div>
            </div>
            <div class="textInfo">
                <form action="index/addcart.action" method="post" name="ECS_FORMBUY" id="ECS_FORMBUY">
                    <h1 class="clearfix">${goods.filmname }</h1>
                    <ul class="ul2 clearfix">
                        <li class="clearfix" style="width: 100%">
                            <dd>
                                <strong>价格：</strong><font class="shop" id="ECS_SHOPPRICE">￥${goods.price }元</font>
                            </dd>
                        </li>
                        <li class="clearfix" style="width: 100%">
                            <dd>
                                <strong>电影类型：</strong><a
                                    href="index/cate.action?id=${goods.cateid }">${goods.catename }</a>
                            </dd>
                        </li>
                        <li class="clearfix" style="width: 100%">
                            <dd>
                                <strong>上映日期：</strong>${goods.thestart}--${goods.theend}
                            </dd>
                        </li>
                        <li class="clearfix" style="width: 100%">
                            <dd>
                                <strong>点击数：</strong>${goods.hits}
                            </dd>
                        </li>
                        <li class="clearfix" style="width: 100%">
                            <dd>
                                <strong>销量：</strong>${goods.sellnum}
                            </dd>
                        </li>
                    </ul>
                    <%--<ul class="bnt_ul">
                        <li class="clearfix">
                            <dd>
                                <strong>购买数量：</strong>
                                <input name="num" type="text" id="number" value="1" size="4"
                                       style="border: 1px solid #ccc;"/>
                                <input type="hidden" name="goodsid" value="${goods.filmid }"/>
                                <input type="hidden" name="price" value="${goods.price }"/>
                            </dd>
                        </li>
                        <li class="padd"><input type="image" src="themes/xecmoban_haier2015/images/goumai2.png"/></li>
                    </ul>--%>
                </form>
            </div>
        </div>
        <div class="blank"></div>
        <div class="box">
            <div style="padding: 0 0px;">
                <div id="com_b" class="history clearfix">
                    <h2>电影描述</h2>
                </div>
                <div id="a" class=""></div>
            </div>
            <div class="box_1">
                <div id="com_v" class="  " style="padding: 6px;"></div>
                <div id="com_h">
                    <blockquote>${goods.contents}</blockquote>
                </div>
            </div>
        </div>
        <div class="blank"></div>
        <div class="box">
            <div style="padding: 0 0px;">
                <div id="filmr" class="history clearfix">
                    <h2>电影场次</h2>
                </div>
                <div id="a1" class=""></div>
            </div>
            <div class="box_1">
                <ul>
                    <li>
                        <ul id="day" class="h6 span1">
                            &nbsp;&nbsp;<div class="right" style="display: inline">日期：</div>
                            <c:forEach items="${days}" var="day">
                                &nbsp;&nbsp;
                                <li style="display: inline">
                                    <a ty="day" id="<fmt:formatDate value='${day}' pattern='yyyy-MM-dd'/>" class="" href="javascript:void(0)"
                                       onclick="getRound1(this)"><span><fmt:formatDate value="${day}"
                                                                                       pattern="yyyy-MM-dd"/></span></a>
                                </li>
                            </c:forEach>
                        </ul>
                    </li>
                    <li>
                        <ul class="f4">
                            &nbsp;&nbsp;<div class="right" style="display: inline">影院：</div>
                            <c:forEach items="${cinemas}" var="c">
                                &nbsp;&nbsp;
                                <li class="li-mini-cart" style="display: inline">
                                    <a ty="cinema" id="${c.cinemaid}" class="" href="javascript:void(0)"
                                       onclick="getRound1(this)"><span>${c.cinemaname}</span></a>
                                </li>
                            </c:forEach>
                        </ul>
                    </li>
                    <li>
                        <ul class="f4">
                            &nbsp;&nbsp;<div class="right" style="display: inline">影厅：</div>
                            <c:forEach items="${halls}" var="c">
                                &nbsp;&nbsp;
                                <li class="li-mini-cart" style="display: inline">
                                    <a ty="hall" id="${c.hallid}" class="" href="javascript:void(0)"
                                       onclick="getRound1(this)"><span>${c.hallname}</span></a>
                                </li>
                            </c:forEach>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="ng-line"></div>
            <div class="box_1" id="mx">
                <table style="width: 100%" class="table">
                    <tr class="tr2">
                        <td><strong>影厅编号</strong></td>
                        <td><strong>影厅名称</strong></td>
                        <td><strong>开始时间</strong></td>
                        <td><strong>散场时间</strong></td>
                        <td><strong>价格</strong></td>
                    </tr>
                    <c:forEach items="${rounds}" var="r">
                        <tr>
                            <td>${r.hall.hallid}</td>
                            <td>${r.hall.hallname}</td>
                            <td>${r.start}</td>
                            <td>${r.end}</td>
                            <td>${r.film.price}元</td>
                            <td>
                                <a class="f_l bnt_blue" href="javascript:void(0)" onclick="goChoice(this)">选座</a>
                            </td>
                        </tr>
                    </c:forEach>
                </table>
            </div>
        </div>

        <div class="blank"></div>
        <div id="ECS_COMMENT">
            <div class="box">
                <div class="box_1">
                    <h3>
                        <span class="text">用户评论</span>(共<font class="f1">${tnum }</font>条评论)
                    </h3>
                    <div class="boxCenterList clearfix" style="height: 1%;">
                        <ul class="comments">
                            <c:forEach items="${topicList}" var="topic">
                                <li class="word"><font class="f2">${topic.username }</font> <font
                                        class="f3">( ${topic.addtime } )</font><br/>
                                    <img src="themes/xecmoban_haier2015/images/stars${topic.num }.gif" alt=""/>
                                    <p>${topic.contents }</p></li>
                            </c:forEach>
                        </ul>
                        <div class="blank5"></div>
                        <div class="commentsList">
                            <form action="index/addTopic.action" method="post" name="commentForm" id="commentForm">
                                <table width="710" border="0" cellspacing="5" cellpadding="0">
                                    <tr>
                                        <td align="right">评分：</td>
                                        <td><input name="num" type="radio" value="1" id="num1"/> <img
                                                src="themes/xecmoban_haier2015/images/stars1.gif"/> <input name="num"
                                                                                                           type="radio"
                                                                                                           value="2"
                                                                                                           id="num2"/>
                                            <img src="themes/xecmoban_haier2015/images/stars2.gif"/> <input name="num"
                                                                                                            type="radio"
                                                                                                            value="3"
                                                                                                            id="num3"/>
                                            <img src="themes/xecmoban_haier2015/images/stars3.gif"/> <input name="num"
                                                                                                            type="radio"
                                                                                                            value="4"
                                                                                                            id="num4"/>
                                            <img src="themes/xecmoban_haier2015/images/stars4.gif"/> <input name="num"
                                                                                                            type="radio"
                                                                                                            value="5"
                                                                                                            checked="checked"
                                                                                                            id="num5"/>
                                            <img
                                                    src="themes/xecmoban_haier2015/images/stars5.gif"/></td>
                                    </tr>
                                    <tr>
                                        <td align="right" valign="top">评论内容：</td>
                                        <td><textarea name="contents" class="inputBorder"
                                                      style="height: 50px; width: 620px;"></textarea> <input
                                                type="hidden" name="goodsid" value="${goods.filmid }"/></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2"><input name="" type="submit" value="评论咨询" class="f_r bnt_blue_1"
                                                               style="margin-right: 8px;"/></td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="footer.jsp"></jsp:include>

</body>
</html>
